import 'package:cbec_app/generated/json/base/json_convert_content.dart';
import 'package:cbec_app/entity/home/content/coupon_decoration_entity.dart';
import 'package:cbec_app/entity/home/content/content_data.dart';

CouponDecorationEntity $CouponDecorationEntityFromJson(Map<String, dynamic> json) {
  final CouponDecorationEntity couponDecorationEntity = CouponDecorationEntity();
  final int? layout = jsonConvert.convert<int>(json['layout']);
  if (layout != null) {
    couponDecorationEntity.layout = layout;
  }
  final String? couponSource = jsonConvert.convert<String>(json['coupon_source']);
  if (couponSource != null) {
    couponDecorationEntity.couponSource = couponSource;
  }
  final String? hideEmptyCoupon = jsonConvert.convert<String>(json['hide_empty_coupon']);
  if (hideEmptyCoupon != null) {
    couponDecorationEntity.hideEmptyCoupon = hideEmptyCoupon;
  }
  final List<CouponDecorationCoupon>? coupon = (json['coupon'] as List<dynamic>?)?.map((e) => jsonConvert.convert<CouponDecorationCoupon>(e) as CouponDecorationCoupon).toList();
  if (coupon != null) {
    couponDecorationEntity.coupon = coupon;
  }
  final int? couponNum = jsonConvert.convert<int>(json['coupon_num']);
  if (couponNum != null) {
    couponDecorationEntity.couponNum = couponNum;
  }
  final String? hideUnsharedCoupon = jsonConvert.convert<String>(json['hide_unshared_coupon']);
  if (hideUnsharedCoupon != null) {
    couponDecorationEntity.hideUnsharedCoupon = hideUnsharedCoupon;
  }
  final int? couponShow = jsonConvert.convert<int>(json['coupon_show']);
  if (couponShow != null) {
    couponDecorationEntity.couponShow = couponShow;
  }
  final int? couponColor = jsonConvert.convert<int>(json['coupon_color']);
  if (couponColor != null) {
    couponDecorationEntity.couponColor = couponColor;
  }
  final int? couponStyle = jsonConvert.convert<int>(json['coupon_style']);
  if (couponStyle != null) {
    couponDecorationEntity.couponStyle = couponStyle;
  }
  final String? uuid = jsonConvert.convert<String>(json['uuid']);
  if (uuid != null) {
    couponDecorationEntity.uuid = uuid;
  }
  return couponDecorationEntity;
}

Map<String, dynamic> $CouponDecorationEntityToJson(CouponDecorationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['layout'] = entity.layout;
  data['coupon_source'] = entity.couponSource;
  data['hide_empty_coupon'] = entity.hideEmptyCoupon;
  data['coupon'] = entity.coupon?.map((v) => v.toJson()).toList();
  data['coupon_num'] = entity.couponNum;
  data['hide_unshared_coupon'] = entity.hideUnsharedCoupon;
  data['coupon_show'] = entity.couponShow;
  data['coupon_color'] = entity.couponColor;
  data['coupon_style'] = entity.couponStyle;
  data['uuid'] = entity.uuid;
  return data;
}

extension CouponDecorationEntityExtension on CouponDecorationEntity {
  CouponDecorationEntity copyWith({
    int? layout,
    String? couponSource,
    String? hideEmptyCoupon,
    List<CouponDecorationCoupon>? coupon,
    int? couponNum,
    String? hideUnsharedCoupon,
    int? couponShow,
    int? couponColor,
    int? couponStyle,
    String? uuid,
  }) {
    return CouponDecorationEntity()
      ..layout = layout ?? this.layout
      ..couponSource = couponSource ?? this.couponSource
      ..hideEmptyCoupon = hideEmptyCoupon ?? this.hideEmptyCoupon
      ..coupon = coupon ?? this.coupon
      ..couponNum = couponNum ?? this.couponNum
      ..hideUnsharedCoupon = hideUnsharedCoupon ?? this.hideUnsharedCoupon
      ..couponShow = couponShow ?? this.couponShow
      ..couponColor = couponColor ?? this.couponColor
      ..couponStyle = couponStyle ?? this.couponStyle
      ..uuid = uuid ?? this.uuid;
  }
}

CouponDecorationCoupon $CouponDecorationCouponFromJson(Map<String, dynamic> json) {
  final CouponDecorationCoupon couponDecorationCoupon = CouponDecorationCoupon();
  final int? pageSize = jsonConvert.convert<int>(json['pageSize']);
  if (pageSize != null) {
    couponDecorationCoupon.pageSize = pageSize;
  }
  final int? targetType = jsonConvert.convert<int>(json['targetType']);
  if (targetType != null) {
    couponDecorationCoupon.targetType = targetType;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    couponDecorationCoupon.remark = remark;
  }
  final int? surplusNum = jsonConvert.convert<int>(json['surplusNum']);
  if (surplusNum != null) {
    couponDecorationCoupon.surplusNum = surplusNum;
  }
  final String? marketingId = jsonConvert.convert<String>(json['marketingId']);
  if (marketingId != null) {
    couponDecorationCoupon.marketingId = marketingId;
  }
  final String? couponId = jsonConvert.convert<String>(json['couponId']);
  if (couponId != null) {
    couponDecorationCoupon.couponId = couponId;
  }
  final int? pageNum = jsonConvert.convert<int>(json['pageNum']);
  if (pageNum != null) {
    couponDecorationCoupon.pageNum = pageNum;
  }
  final String? sid = jsonConvert.convert<String>(json['sid']);
  if (sid != null) {
    couponDecorationCoupon.sid = sid;
  }
  final String? shopNames = jsonConvert.convert<String>(json['shopNames']);
  if (shopNames != null) {
    couponDecorationCoupon.shopNames = shopNames;
  }
  final String? activityDate = jsonConvert.convert<String>(json['activityDate']);
  if (activityDate != null) {
    couponDecorationCoupon.activityDate = activityDate;
  }
  final int? totalNum = jsonConvert.convert<int>(json['totalNum']);
  if (totalNum != null) {
    couponDecorationCoupon.totalNum = totalNum;
  }
  final int? useNum = jsonConvert.convert<int>(json['useNum']);
  if (useNum != null) {
    couponDecorationCoupon.useNum = useNum;
  }
  final String? couponType = jsonConvert.convert<String>(json['couponType']);
  if (couponType != null) {
    couponDecorationCoupon.couponType = couponType;
  }
  final String? ruleType = jsonConvert.convert<String>(json['ruleType']);
  if (ruleType != null) {
    couponDecorationCoupon.ruleType = ruleType;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    couponDecorationCoupon.name = name;
  }
  final int? receiveNum = jsonConvert.convert<int>(json['receiveNum']);
  if (receiveNum != null) {
    couponDecorationCoupon.receiveNum = receiveNum;
  }
  final String? targetTypeName = jsonConvert.convert<String>(json['targetTypeName']);
  if (targetTypeName != null) {
    couponDecorationCoupon.targetTypeName = targetTypeName;
  }
  final String? syncOnline = jsonConvert.convert<String>(json['syncOnline']);
  if (syncOnline != null) {
    couponDecorationCoupon.syncOnline = syncOnline;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    couponDecorationCoupon.status = status;
  }
  return couponDecorationCoupon;
}

Map<String, dynamic> $CouponDecorationCouponToJson(CouponDecorationCoupon entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pageSize'] = entity.pageSize;
  data['targetType'] = entity.targetType;
  data['remark'] = entity.remark;
  data['surplusNum'] = entity.surplusNum;
  data['marketingId'] = entity.marketingId;
  data['couponId'] = entity.couponId;
  data['pageNum'] = entity.pageNum;
  data['sid'] = entity.sid;
  data['shopNames'] = entity.shopNames;
  data['activityDate'] = entity.activityDate;
  data['totalNum'] = entity.totalNum;
  data['useNum'] = entity.useNum;
  data['couponType'] = entity.couponType;
  data['ruleType'] = entity.ruleType;
  data['name'] = entity.name;
  data['receiveNum'] = entity.receiveNum;
  data['targetTypeName'] = entity.targetTypeName;
  data['syncOnline'] = entity.syncOnline;
  data['status'] = entity.status;
  return data;
}

extension CouponDecorationCouponExtension on CouponDecorationCoupon {
  CouponDecorationCoupon copyWith({
    int? pageSize,
    int? targetType,
    String? remark,
    int? surplusNum,
    String? marketingId,
    String? couponId,
    int? pageNum,
    String? sid,
    String? shopNames,
    String? activityDate,
    int? totalNum,
    int? useNum,
    String? couponType,
    String? ruleType,
    String? name,
    int? receiveNum,
    String? targetTypeName,
    String? syncOnline,
    int? status,
  }) {
    return CouponDecorationCoupon()
      ..pageSize = pageSize ?? this.pageSize
      ..targetType = targetType ?? this.targetType
      ..remark = remark ?? this.remark
      ..surplusNum = surplusNum ?? this.surplusNum
      ..marketingId = marketingId ?? this.marketingId
      ..couponId = couponId ?? this.couponId
      ..pageNum = pageNum ?? this.pageNum
      ..sid = sid ?? this.sid
      ..shopNames = shopNames ?? this.shopNames
      ..activityDate = activityDate ?? this.activityDate
      ..totalNum = totalNum ?? this.totalNum
      ..useNum = useNum ?? this.useNum
      ..couponType = couponType ?? this.couponType
      ..ruleType = ruleType ?? this.ruleType
      ..name = name ?? this.name
      ..receiveNum = receiveNum ?? this.receiveNum
      ..targetTypeName = targetTypeName ?? this.targetTypeName
      ..syncOnline = syncOnline ?? this.syncOnline
      ..status = status ?? this.status;
  }
}
